
package com.wobaby.util.xml;

import org.w3c.dom.*;

// Referenced classes of package com.wobaby.util.xml:
//            NodeListVector

public class DOMNodeHelper
{

    public DOMNodeHelper()
    {
    }

    public static NodeList findNodesOfType(Node parent, String type)
    {
        NodeListVector retval = new NodeListVector();
        NodeList childNodes = parent.getChildNodes();
        Node candidateNode = null;
        if(childNodes != null)
        {
            int numNodes = childNodes.getLength();
            for(int index = 0; index < numNodes; index++)
            {
                candidateNode = childNodes.item(index);
                if(candidateNode != null && candidateNode.getNodeName().equals(type))
                    retval.add(candidateNode);
            }

        }
        return retval;
    }

    public static String getAttributeValue(Node parentNode, String attrName)
    {
        NamedNodeMap elementAttrs = parentNode.getAttributes();
        Node attributeNode = elementAttrs.getNamedItem(attrName);
        String attributeValue = null;
        if(attributeNode != null)
            attributeValue = attributeNode.getNodeValue();
        return attributeValue;
    }
}